#include "Ogre.h"
#include "GameEngine.h"
#include "Actor.h"

static CActor* mFirstActor = NULL;

CActor::CActor()
{
	mPrevActor = NULL;
	mNextActor = mFirstActor;
	mFirstActor = this;
	if(mNextActor) mNextActor->mPrevActor = this;

	mSceneNode = CGameEngine::getSingletonPtr()->getSceneManager()->getRootSceneNode()->createChildSceneNode();
}

CActor::~CActor()
{
	CGameEngine::getSingletonPtr()->getSceneManager()->destroySceneNode(mSceneNode);

	if(mNextActor)
	{
		mNextActor->mPrevActor = mPrevActor;
	}

	if(mPrevActor)
	{
		mPrevActor->mNextActor = mNextActor;
	}
	else
	{
		mFirstActor = mNextActor;
	}
}

void CActor::tick(Ogre::Real delta)
{
	tickAnimation(delta);
	tickLogic(delta);
}

void CActor::tickAll(Ogre::Real delta)
{
	CActor* i = mFirstActor;
	while(i)
	{
		i->tick(delta);
		i = i->mNextActor;
	}
}

void CActor::tickAnimation(Ogre::Real delta)
{
}

void CActor::tickLogic(Ogre::Real delta)
{
}
